API Documentation
Public Member Functions | List of all members
nkExport::Node Class Referencefinal

A node in the tree structure representing the data to export / import. More...

Public Member Functions

 Node ()
 
 ~Node ()
 
NODE_NATURE getNodeNature () const
 
NODE_VALUE_TYPE getNodeValueType () const
 
bool isValueTypeNumber () const
 
nkMemory::StringView getValueAsString () const
 
int getValueAsInt () const
 
unsigned int getValueAsUint () const
 
long long getValueAsLong () const
 
unsigned long long getValueAsUlong () const
 
float getValueAsFloat () const
 
double getValueAsDouble () const
 
bool getValueAsBool () const
 
unsigned int getMemberCount () const
 
nkMemory::StringView getMemberKey (unsigned int index)
 
NodegetMemberValue (unsigned int index)
 
NodegetMemberValue (const nkMemory::StringView &key)
 
unsigned int getArraySize () const
 
NodegetArrayElement (unsigned int index)
 
void * getUserData () const
 
void setAsString (const nkMemory::StringView &value)
 
void setAsInt (int value)
 
void setAsUint (unsigned int value)
 
void setAsLong (long long value)
 
void setAsUlong (unsigned long long value)
 
void setAsFloat (float value)
 
void setAsDouble (double value)
 
void setAsBool (bool value)
 
NodeaddMember (const nkMemory::StringView &key)
 
void deleteMember (const nkMemory::StringView &key)
 
NodeaddElement ()
 
void setUserData (void *value)
 

Detailed Description

A node in the tree structure representing the data to export / import.

Constructor & Destructor Documentation

◆ Node()

nkExport::Node::Node ( )

Constructor.

◆ ~Node()

nkExport::Node::~Node ( )

Destructor.

Member Function Documentation

◆ getNodeNature()

NODE_NATURE nkExport::Node::getNodeNature ( ) const
Returns
The nature of the node. The nature of the node describes the kind of data you can expect to be able to retrieve from it.

◆ getNodeValueType()

NODE_VALUE_TYPE nkExport::Node::getNodeValueType ( ) const
Returns
The value type of the value this node holds. This describes precisely what the value inside the node is, to call the right accessor.

◆ isValueTypeNumber()

bool nkExport::Node::isValueTypeNumber ( ) const
Returns
Whether the node has any kind of number value type inside (int, uint, long, ulong, float, double).

◆ getValueAsString()

nkMemory::StringView nkExport::Node::getValueAsString ( ) const
Returns
The value cast as a string.
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely end in a crash.

◆ getValueAsInt()

int nkExport::Node::getValueAsInt ( ) const
Returns
The value cast as an int.
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getValueAsUint()

unsigned int nkExport::Node::getValueAsUint ( ) const
Returns
The value cast as an unsigned int.
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getValueAsLong()

long long nkExport::Node::getValueAsLong ( ) const
Returns
The value cast as a long (8 bytes).
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getValueAsUlong()

unsigned long long nkExport::Node::getValueAsUlong ( ) const
Returns
The value cast as an unsigned long (8 bytes).
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getValueAsFloat()

float nkExport::Node::getValueAsFloat ( ) const
Returns
The value cast as a float.
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getValueAsDouble()

double nkExport::Node::getValueAsDouble ( ) const
Returns
The value cast as a double.
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getValueAsBool()

bool nkExport::Node::getValueAsBool ( ) const
Returns
The value cast as a bool.
Remarks
Beware that the value is retained via an union internally. If called while holding a different type, this will most likely return garbage.

◆ getMemberCount()

unsigned int nkExport::Node::getMemberCount ( ) const
Returns
The number of members the node has.

◆ getMemberKey()

nkMemory::StringView nkExport::Node::getMemberKey ( unsigned int  index)

Allows to retrieve a key of a member, like if they were indexable. Can be used to inspect an unknown structure, for instance.

Parameters
indexThe index of the member key to retrieve. For instance, if a node has 5 members, it would be possible to index them from 0 to 4.
Returns
The key of the member at index requested. If index is out of bounds, an empty string.

◆ getMemberValue() [1/2]

Node* nkExport::Node::getMemberValue ( unsigned int  index)

Allows to retrieve a member, like if they were indexable. See nkExport::Node::getMemberKey for more details.

Parameters
indexThe index of the member to retrieve.
Returns
The member at requested index. If index is out of bounds, nullptr.

◆ getMemberValue() [2/2]

Node* nkExport::Node::getMemberValue ( const nkMemory::StringView key)

Allows to get a member directly from its key.

Parameters
keyThe key identifying the wanted member.
Returns
The member at requested key. If none is existing, nullptr.

◆ getArraySize()

unsigned int nkExport::Node::getArraySize ( ) const
Returns
The size of the array represented by the node.

◆ getArrayElement()

Node* nkExport::Node::getArrayElement ( unsigned int  index)
Parameters
indexThe index at which to index the array.
Returns
The attached element. If index is out of bounds, nullptr.

◆ getUserData()

void* nkExport::Node::getUserData ( ) const
Returns
The user data attached to the node.

◆ setAsString()

void nkExport::Node::setAsString ( const nkMemory::StringView value)

Converts the node to hold a string.

Parameters
valueThe string to attach to this node.

◆ setAsInt()

void nkExport::Node::setAsInt ( int  value)

Converts the node to hold an int.

Parameters
valueThe int to attach to this node.

◆ setAsUint()

void nkExport::Node::setAsUint ( unsigned int  value)

Converts the node to hold an unsigned int.

Parameters
valueThe unsigned int to attach to this node.

◆ setAsLong()

void nkExport::Node::setAsLong ( long long  value)

Converts the node to hold a long (8 bytes).

Parameters
valueThe long to attach to this node.

◆ setAsUlong()

void nkExport::Node::setAsUlong ( unsigned long long  value)

Converts the node to hold an unsigned long (8 bytes).

Parameters
valueThe unsigned long to attach to this node.

◆ setAsFloat()

void nkExport::Node::setAsFloat ( float  value)

Converts the node to hold a float.

Parameters
valueThe float to attach to this node.

◆ setAsDouble()

void nkExport::Node::setAsDouble ( double  value)

Converts the node to hold a double.

Parameters
valueThe double to attach to this node.

◆ setAsBool()

void nkExport::Node::setAsBool ( bool  value)

Converts the node to hold a boolean.

Parameters
valueThe bool to attach to this node.

◆ addMember()

Node* nkExport::Node::addMember ( const nkMemory::StringView key)

Converts the node as an object to hold child members.

Parameters
keyThe key of the member to add.
Returns
The child member, empty.
Remarks
The node is responsible for freeing the child member. You don't need to free the returned pointer after use.

◆ deleteMember()

void nkExport::Node::deleteMember ( const nkMemory::StringView key)

Allows to erase a member from the node.

Parameters
keyThe key of the member to delete.
Remarks
This will also free the memory of the child node, if existing.

◆ addElement()

Node* nkExport::Node::addElement ( )

Converts the node into an array to index children.

Returns
A new child, empty.
Remarks
The node is responsible for freeing the child. You don't need to free the returned pointer after use.

◆ setUserData()

void nkExport::Node::setUserData ( void *  value)

Allows to attach user data to the node. This data is ignored by the component, and can be used by the client application if any information needs to be communicated by this mean.

Parameters
valueThe data to attach to this node.

The documentation for this class was generated from the following file: